package com.sky.mapper;

import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 目标:
 *
 * @author YUE
 * @date 2024/6/17 16:53
 */
@Mapper
public interface ShoppingCartMapper {


    @Update("update shopping_cart set number = #{number} where id = #{id}")
    void updateByNumber(int number, Long id);
    @Insert("insert into shopping_cart(name, image, user_id, dish_id, setmeal_id, dish_flavor, amount, create_time) values" +
            " (#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{amount},#{createTime})")
    void inster(ShoppingCart shoppingCart);

    /*
      根据用户id查询购物车
     */
    @Select("select * from shopping_cart where user_id = #{userId}")
    List<ShoppingCart> getByUserId(Long userId);

    @Delete("delete from shopping_cart where user_id = #{userId}")
    void deleteShoppingCart(Long currentId);

    List<ShoppingCart> userList(ShoppingCart shoppingCart);

    @Delete("delete from shopping_cart where id = #{id}")
    void deleteGoods(Long id);

}
